<%@ page import="java.util.List" %>
<%@ page import="cn.acmoj.oj.bean.Problem" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>${applicationScope.ojName}</title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.flat.min.css"/>
    <style>
        .main {
            width: 60%;
            margin: 0 auto;
        }

        .title {
            background: #FFF;
            border-bottom: solid 1px #CCCCCC;
            padding: 10px;
            margin-bottom: 30px;
        }

        .title h2 {
            font-size: 2em;
            width: 100%;
            text-align: center;
        }

        .acnum,
        .num,
        .rate {
            width: 15%;
        }

        .id {
            width: 8%;
        }
    </style>
</head>

<body>

<jsp:include page="/contest/heard.html" flush="true"/>

<div class="title">
    <div class="main">
        <h2>${requestScope.contest.title} </h2>
        <p>${requestScope.contest.content}</p>
    </div>
</div>

<div class="main">
    <table class="am-table am-table-bordered am-table-hover">
        <thead>
        <tr>
            <th>编号</th>
            <th>名称</th>
            <th>通过人数</th>
            <th>提交人数</th>
            <th>通过率</th>
        </tr>
        </thead>
        <tbody>
        <%
            List<Problem> list = (List<Problem>) request.getAttribute("list");
            List<Integer> l = (List<Integer>) request.getAttribute("list_s");
            for (int i = 0; i < list.size(); i++) {
                Problem problem = list.get(i);
                if (session.getAttribute("user") != null) {
                    if (l.get(i) == 0) {
        %>
        <tr>
                <%
                    } else if (l.get(i) == 1) {
        %>
        <tr class="am-success">
                <%
                    } else {
                %>
        <tr class="am-danger">
            <%
                    }
                }
            %>
            <td class="id">
                <a href="${pageContext.request.contextPath}/contest/problem.html?cid=${sessionScope.cid}&pid=<%=(char)(i + 'A')%>"><%=(char) (i + 'A')%>
                </a>
            </td>
            <td>
                <a href="${pageContext.request.contextPath}/contest/problem.html?pid=<%=(char)(i + 'A')%>">
                    <%=problem.getTitle().isEmpty() ? "Problem " + (char) (i + 'A') : problem.getTitle()%>
                </a>
            </td>
            <td class="acnum"><%=problem.getAccepted()%>
            </td>
            <td class="num"><%=problem.getSubmit()%>
            </td>
            <td class="rate"><%=problem.getSubmit() == 0 ? 0 : problem.getAccepted() * 100 / problem.getSubmit()%>%</td>
        </tr>
        <%
            }
        %>
        </tbody>
    </table>
    <div class="am-panel am-panel-default">
        <div class="am-panel-hd">比赛资讯</div>
        <div class="am-panel-bd">
            ${requestScope.contest.description}
        </div>
        <%--<ul class="am-list am-list-static am-list-border">--%>
        <%--<li>A题数据范围改为[1,10000]</li>--%>
        <%--<li>C题已重判</li>--%>
        <%--<li>你不懂我，我不怪你。</li>--%>
        <%--<li>每个人都有一道伤口， 或深或浅，盖上布，以为不存在。</li>--%>
        <%--</ul>--%>
    </div>
</div>

<jsp:include page="/foot.html" flush="true"/>

<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/amazeui.min.js"></script>
<script>
    $(function () {
        $('.problemset').addClass('am-active');
    })
</script>
</body>

</html>
<!--http://contests.acmicpc.info/contests.json-->
<!--数据来源：http://contests.acmicpc.info/contests.json-->